Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure-rest/core-client

Package Overview
Dependencies
Maintainers
2
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure-rest/core-client

Core library for interfacing with Azure Rest Clients

  • 2.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
253K
increased by2.8%
Maintainers
2
Weekly downloads
 
Created

What is @azure-rest/core-client?

@azure-rest/core-client is a core library for building Azure SDKs using the REST client. It provides essential functionalities for making HTTP requests, handling responses, and managing client configurations. This package is designed to be used as a foundational component for other Azure SDK libraries.

What are @azure-rest/core-client's main functionalities?

Creating a REST Client

This feature allows you to create a REST client instance that can be used to interact with Azure services. The `createClient` function initializes the client with a base URL.

const { createClient } = require('@azure-rest/core-client');
const client = createClient('https://example.azure.com');

Making GET Requests

This feature demonstrates how to make a GET request to a specified path using the REST client. The response body is then logged to the console.

const response = await client.path('/resource').get();
console.log(response.body);

Making POST Requests

This feature shows how to make a POST request with a JSON body. The response body is then logged to the console.

const response = await client.path('/resource').post({ body: { key: 'value' } });
console.log(response.body);

Handling Responses

This feature demonstrates how to handle responses from the REST client. It checks the status code and logs either a success message with the response body or an error message with the status code.

const response = await client.path('/resource').get();
if (response.status === 200) {
  console.log('Success:', response.body);
} else {
  console.log('Error:', response.status);
}

Configuring Client Options

This feature shows how to configure client options such as headers when creating a REST client instance. In this example, an Authorization header is added to the client.

const { createClient } = require('@azure-rest/core-client');
const client = createClient('https://example.azure.com', { headers: { 'Authorization': 'Bearer token' } });

Other packages similar to @azure-rest/core-client

Keywords

FAQs

Package last updated on 11 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc